package com.codeoss.framework.webide.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.codeoss.framework.webide.request.WorkflowWizardDialogRequest;
import com.codeoss.framework.webide.response.WorkflowWizardDialogResponse;
import com.codeoss.framework.webide.service.IWorkflowWizardDialogService;

@Controller
@RequestMapping("webide/workflowwizarddialog")
public class WorkflowWizardDialogController {
	@Autowired
	private IWorkflowWizardDialogService workflowWizardDialogService;

	@RequestMapping(value = "onFinish", method = RequestMethod.POST)
	@ResponseBody
	public WorkflowWizardDialogResponse onFinish(@RequestBody WorkflowWizardDialogRequest workflowWizardDialogRequest) {
		WorkflowWizardDialogResponse workflowWizardDialogResponse = workflowWizardDialogService.onFinish(workflowWizardDialogRequest);
		return workflowWizardDialogResponse;
	}
	
	@RequestMapping(value = "initModuleTypeSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowWizardDialogResponse initModuleTypeSelectPage() {
		WorkflowWizardDialogResponse workflowWizardDialogResponse = workflowWizardDialogService.initModuleTypeSelectPage();
		return workflowWizardDialogResponse;
	}
	
	@RequestMapping(value = "initApprovalConfigPage", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowWizardDialogResponse initApprovalConfigPage() {
		WorkflowWizardDialogResponse workflowWizardDialogResponse = workflowWizardDialogService.initApprovalConfigPage();
		return workflowWizardDialogResponse;
	}
	
	@RequestMapping(value = "initFormPageSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowWizardDialogResponse initFormPageSelectPage() {
		WorkflowWizardDialogResponse workflowWizardDialogResponse = workflowWizardDialogService.initFormPageSelectPage();
		return workflowWizardDialogResponse;
	}
	
	@RequestMapping(value = "initModelSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowWizardDialogResponse initModelSelectPage() {
		WorkflowWizardDialogResponse workflowWizardDialogResponse = workflowWizardDialogService.initModelSelectPage();
		return workflowWizardDialogResponse;
	}
	
	@RequestMapping(value = "onTableSelectChangeHandler", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowWizardDialogResponse onTableSelectChangeHandler(@RequestParam("tableName") String tableName) {
		WorkflowWizardDialogResponse workflowWizardDialogResponse = workflowWizardDialogService.onTableSelectChangeHandler(tableName);
		return workflowWizardDialogResponse;
	}
}
